package com.zygh.policeasset.controller;

import cn.hutool.core.util.StrUtil;
import com.zygh.policeasset.component.CommonResult;
import com.zygh.policeasset.pojo.Category;
import com.zygh.policeasset.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping({"/category"})
@Api(tags = {"项目分类"})
@RestController
/* loaded from: police-asset-2.0-0.0.1-SNAPSHOT.jar:BOOT-INF/classes/com/zygh/policeasset/controller/CategoryController.class */
public class CategoryController {
    @Autowired
    CategoryService categoryService;

    @RequestMapping(value = {"/"}, method = {RequestMethod.GET})
    @ApiOperation("获取项目分类列表")
    public Object getAll() {
        return this.categoryService.findAll();
    }

    @RequestMapping(value = {"/id"}, method = {RequestMethod.GET})
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query")})
    @ApiOperation("通过ID获取分类")
    public Object remove(@RequestBody Category params) {
        if (StrUtil.isEmpty(String.valueOf(params.getId()))) {
            return new CommonResult().validateFailed("ID不能为空");
        }
        return this.categoryService.findById(params.getId());
    }
}